<template>
  <div class="login">
    <div class="login-cont">
      <h2>新雨池二期登录</h2>
      <el-form
        ref="ruleForm"
        :model="formlogin"
        label-width="0"
        :rules="rulesConfig"
      >
        <!-- <el-form-item prop="merchant">
          <el-input
            v-model="formlogin.merchant"
            placeholder="请输入租户编码"
          ></el-input>
        </el-form-item> -->
        <el-form-item prop="username">
          <el-input
            prefix-icon="el-icon-user-solid"
            v-model="formlogin.username"
            placeholder="请输入账户名"
          ></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            prefix-icon="el-icon-s-goods"
            v-model="formlogin.password"
            placeholder="请输入密码"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button   @click="submitForm('ruleForm')"  class="btn"
            >立即登录</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import rulesConfig from "./config/rule";
import { gettoken } from "@/api/login";
import { mapState}  from "vuex"
export default {
  name: "login",
  data() {
    return {
      rulesConfig,

      formlogin: {
        username: "admin",
        password: 123456,
        token:'',
      },
    };
  },
  computed : {
  },
  methods: {
    submitForm(formlogin) {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
              this.$store.dispatch("loginAction",this.formlogin);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
   async created(){
    var {data} = await gettoken()
    this.formlogin.token= data.code
  }
}
</script>

<style scoped lang="less">
.login {
  width: 100%;
  height: 100vh;
  background-image: url("~assets/login.jpg");
  background-size: cover;
  .login-cont {
    width: 320px;
    height: 380px;
    background: #fff;
    text-align: center;
    float: right;
    margin: 15% 10% 0 0;
    padding: 40px;
    // opacity: .6;
    // border-radius: 20px;
    h2 {
      line-height: 50px;
    }
    .el-input {
      margin-top: 10px;
    }
    .btn {
      box-shadow: 0px 3px 9px #009380!important ;
      width: 100%;
      background-color: #009380!important;
      color: #fff!important;
      font-weight: 900;
      margin-top: 100px;
    }
    /deep/.el-input__prefix {
      color: #777777!important;
    }
  }
}
</style>
